package com.rc.web.controller;


import com.rc.pojo.vo.file.UploadVO;
import com.rc.web.service.FileService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.constraints.NotNull;

@CrossOrigin(origins = "*")  //这个注解是允许跨域请求的
@RestController
@RequestMapping("/file")
@Api(tags = "文件")
@RequiredArgsConstructor
@Validated
@Slf4j
public class FileController {
    private final FileService fileService;

    @PostMapping("/upload")
    public UploadVO upload(@RequestBody @NotNull(message = "不许乱点") MultipartFile file) throws Exception {
        return fileService.upload(file);
    }


}
